<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <!-- 
            注意：使用key地特殊属性，它会基于key地变化进行元素重新排序，并且会移除key不存在的元素
         -->
        <h3>1.迭代数组</h3>
        <ul>
            <li v-for="(stu,index) in Students" :key="stu.id">
                编号:{{index+1}} 姓名:{{stu.name}} 年龄:{{stu.age}}
            </li>
        </ul>
        <h3>2.迭代对象</h3>
        <ul>
            <!-- 可以使用in或者of作为分隔符，他们两个没有什么明显区别 -->
            <li v-for="(key,value,index) of person">
                第{{index+1}}个元素，key为:{{key}} value为:{{value}}
            </li>
        </ul>
    </div>
    <script src="./node_modules/vue/dist/vue.js"></script>
    <script>
        var vm = new Vue({
            el:"#app",
            data:{
                Students:[
                    {id:"1",name:"xiaobai",age:"21"},
                    {id:"2",name:"xiaoshen",age:"21"},
                    {id:"3",name:"xiaowang",age:"21"},
                ],
                person:{
                    id:"1",
                    name:"xiaochen",
                    age:"22",
                }
            },
        })
    </script>
</body>
</html>